/*
 ============================================================================
 Name		: RtWeiboAppUi.cpp
 Author	  : hou maoqing
 Copyright   : Your copyright notice
 Description : CRtWeiboAppUi implementation
 ============================================================================
 */

// INCLUDE FILES
#include <avkon.hrh>
#include <aknmessagequerydialog.h>
#include <aknnotewrappers.h>
#include <stringloader.h>
#include <f32file.h>
#include <s32file.h>

#include "RtWeibo.hrh"
#include "RtWeibo.pan"
#include "RtWeiboApplication.h"
#include "RtWeiboAppUi.h"
#include "RtWeiboAppView.h"
#include "RtWindow.h"

// -----------------------------------------------------------------------------
// CRtWeiboAppUi::ConstructL()
// Symbian 2nd phase constructor can leave.
// -----------------------------------------------------------------------------
//
void CRtWeiboAppUi::ConstructL()
	{
	// Initialise app UI with standard value.
	BaseConstructL(CAknAppUi::EAknEnableSkin);
	
	iAppView=CRtWeiboAppView::NewL(ApplicationRect());
	this->AddToStackL(iAppView);
	
	m_pRtWeiboApp=CreateUiManager();
	
	TRect r=ApplicationRect();
	CRtRect rect(r.iTl.iX,r.iTl.iY,r.iBr.iX,r.iBr.iY);
	
	CCoeControl* pCoeControl=iAppView;
	CRtWindow* pWnd=new CRtWindow(pCoeControl);
	CRtControl* pParent=new CRtControl(pWnd);
	pParent->SetRect(rect);
	
	m_pRtWeiboApp->SetPlatWindow(pParent);
	m_pRtWeiboApp->SetObserver(this);
	m_pRtWeiboApp->SetScreenRect(rect);
	m_pRtWeiboApp->Start();
	
	return;
	}
// -----------------------------------------------------------------------------
// CRtWeiboAppUi::CRtWeiboAppUi()
// C++ default constructor can NOT contain any code, that might leave.
// -----------------------------------------------------------------------------
//
CRtWeiboAppUi::CRtWeiboAppUi()
	{
	m_pRtWeiboApp=NULL;
	m_pTimer=NULL;
	}

// -----------------------------------------------------------------------------
// CRtWeiboAppUi::~CRtWeiboAppUi()
// Destructor.
// -----------------------------------------------------------------------------
//
CRtWeiboAppUi::~CRtWeiboAppUi()
	{
	if(m_pTimer)
		{
		delete m_pTimer;
		m_pTimer=NULL;
		}
	if(m_pRtWeiboApp)
		{
		m_pRtWeiboApp->Release();
		m_pRtWeiboApp=NULL;
		}
	
	RemoveFromStack(iAppView);
	if (iAppView)
		{
		delete iAppView;
		iAppView = NULL;
		}
	
	}

// -----------------------------------------------------------------------------
// CRtWeiboAppUi::HandleCommandL()
// Takes care of command handling.
// -----------------------------------------------------------------------------
//
void CRtWeiboAppUi::HandleCommandL(TInt aCommand)
	{
	switch (aCommand)
		{
		case EEikCmdExit:
		case EAknSoftkeyExit:
			Exit();
			break;
			
		default:
			//Panic(ERtWeiboUi);
			break;
		}
	}
// -----------------------------------------------------------------------------
//  Called by the framework when the application status pane
//  size is changed.  Passes the new client rectangle to the
//  AppView
// -----------------------------------------------------------------------------
//
void CRtWeiboAppUi::HandleStatusPaneSizeChange()
	{
	iAppView->SetRect(ClientRect());
	}

void CRtWeiboAppUi::HandleUiExit()
	{
	m_pTimer=new CRtSingleTimer(*this,1);
	m_pTimer->After(50*1000);
	}

void CRtWeiboAppUi::NotifyDraw()
	{
	if(iAppView)
		iAppView->DrawDeferred();
	}

void CRtWeiboAppUi::Create2SendSms(const char* pText,int nLen)
	{
	
	}

void CRtWeiboAppUi::MakeNewCall(const char* pText,int nLen)
	{
	
	}

void CRtWeiboAppUi::TimerFinished(TInt nID)
	{
	this->Exit();
	}

// End of File
